<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<script type="text/javascript" src="X-admin/js/jquery.min.js" ></script>
		
		<script type="text/javascript">
			 
			  function checkUname(){
			  	  var name =$("#name").val();
			  	  var na=/^[\u4e00-\u9fa5]{2,5}/;
			  	  
			  	  if(name==""){
			  	  	$("#textname").text("");
			  	  	return false;
			  	  
			  	  }else if(!na.test(name)){
			  	  	
			  	  	$("#textname").text("X").css("color","red");
			  	  	return false;
			  	  }else{
			  	  	
			  	  	$("#textname").text("ok").css("color","red");
			  	  	return true;
			  	  }
			  	  
			  	  	
			  	  
			  }
			  
			  function checknation(){
			  	  var action =$("#nation").val();
			  	  var na=/^[\u4e00-\u9fa5]{1,}/;
			  	  
			  	  if(action==""){
			  	  	$("#textnation").text("");
			  	  	return false;
			  	  
			  	  }else if(!na.test(action)){
			  	  	
			  	  	$("#textnation").text("X").css("color","red");
			  	  	return false;
			  	  }else{
			  	  	
			  	  	$("#textnation").text("ok").css("color","red");
			  	  	return true;
			  	  }
			  	  
			  	  	
			  	  
			  }
			  
			  function checkcard(){
			  	
			  	  var card =$("#card").val();
			  	  var na=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
			  	  
			  	  if(card==""){
			  	  	$("#textcard").text("");
			  	  	return false;
			  	  
			  	  }else if(!na.test(card)){
			  	  	
			  	  	$("#textcard").text("X").css("color","red");
			  	  	return false;
			  	  }else{
			  	  	
			  	  	$("#textcard").text("ok").css("color","red");
			  	  	return true;
			  	  }
			  }
			  
			  function checkfile(){
				  var filepath = $("input[name='file']").val();
				  
				  if(filepath==null && filepath==""){
					  return false;
				  }
			      var extStart = filepath.lastIndexOf(".");
			      var ext = filepath.substring(extStart, filepath.length).toUpperCase();
			      
			      if (ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
			    	  
			    	  alert("图片限于bmp,png,gif,jpeg,jpg格式");
			    	  
			          return false;
			      } 
			      
			      
			        var file_size = 0;
			        if ($.browser.msie) {
			          var img = new Image();
			          img.src = filepath;
			          while (true) {
			            if (img.fileSize > 0) {
			              if (img.fileSize > 3 * 1024 * 1024) {
			                alert("图片不大于100MB。");
			                return false;
			              } 
			              break;
			            }
			          }
			        } else {
			          file_size = this.files[0].size;
			          var size = file_size / 1024;
			          if (size > 10240) {
			            alert("上传的图片大小不能超过10M！");
			            return false;
			          }
			        }
			        $("#img").text("ok").css("color","red");
			        return true;
			  
			  }
			  
			  function checkAll(){
			  	 var x= checkUname();
			  	 var y= checknation();
			  	 var z= checkcard();
			  	 var e=checkfile();
			  	 
			  	 if(x||y||z){
			  	 	return true;
			  	 }else{
			  	 	if(!x){
			  	 		$("#textname").text("X").css("color","red");
			  	 		
			  	 	}
			  	 	if(!y){
			  	 		$("#textnation").text("X").css("color","red");
			  	 	}
			  	 	
			  	 	if(!z){
			  	 		$("#textcard").text("X").css("color","red");
			  	 	}
			  	 	
			  	 	if(!e){
			  	 		
			  	 		$("#img").text("X").css("color","red");
			  	 	}
			  	 	return false;
			  	 }
			  	
			  }
		</script>
<body>
   <form action="addUser.s" onsubmit="return checkAll()" method="post" enctype="multipart/form-data"/>
			姓名：<input type="text" name="usrName" id="name"   placeholder=" 2 - 4个汉字" onblur="checkUname()" />
			<span id="textname"></span>
			<br/>
			性别：
			<input type="radio" name="userinfoSex" value="男" checked="checked"/>男
			<input type="radio" name="userinfoSex" value="女"/>女
			
			<br/>
			民族：<input type="text" name="userinfoNat" id="nation" onblur="checknation()"/>
			<span id="textnation"></span>
			<br/>
			出生：<input type="date" name="userinfoBirthday" id="date" value="" required/><br/>
			住址：<input type="text" name="userinfoAddress" id="action" value="" required/><br/>
			公民身份证号：<input type="text" name="userinfoCard" id="card" value="" onblur="checkcard()"/>
			<span id="textcard"></span>
			<br/>
			
			
			职称：
			<select name="srRoleId">
				<option value="0">普通员工</option>
			</select>
			
			图片：<input type="file" value="上传" name="file" onblur="checkfile()">
			<span id="img"></span>
			<br/>
			<input type="submit" name="button" id="button" value="确认" />
			
			
	</form>
</body>
</html>